package com.ruoyi.project.system.domain.vo;

import com.ruoyi.project.system.domain.SiyuProduct;
import com.ruoyi.project.system.domain.SiyuUserPrice;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;

@Data
@NoArgsConstructor
public class ProductPriceVo {

    private Integer id;

    private String name;

    private String code;

    private String explain;

    private Boolean status;

    private String remark;

    private Boolean isSystemPrice;

    private BigDecimal price;

    public ProductPriceVo(SiyuProduct siyuProduct) {
        this.id = siyuProduct.getId();
        this.code = siyuProduct.getCode();
        this.name = siyuProduct.getName();
        this.explain = siyuProduct.getExplain();
        this.remark = siyuProduct.getRemark();
        this.status = "0".equals(siyuProduct.getStatus());

        this.isSystemPrice = true;
        this.price = siyuProduct.getUnitPrice();
    }

    public ProductPriceVo(SiyuProduct siyuProduct, SiyuUserPrice siyuUserPrice) {
        this(siyuProduct);
        this.isSystemPrice = false;
        this.price = siyuUserPrice.getPrice();
    }

    public ProductPriceVo(ProductEnable productEnable) {
        this((SiyuProduct) productEnable);
        if ("0".equals(productEnable.getDefaultAvailable()) || "0".equals(productEnable.getAvailable())) {
            return;
        }
        this.status = false;
        this.remark = productEnable.getDefaultNoAvailableMsg();
    }

    public ProductPriceVo(ProductEnable productEnable, SiyuUserPrice siyuUserPrice) {
        this((SiyuProduct) productEnable, siyuUserPrice);
        if ("0".equals(productEnable.getDefaultAvailable()) || "0".equals(productEnable.getAvailable())) {
            return;
        }
        this.status = false;
        this.remark = productEnable.getDefaultNoAvailableMsg();
    }

}
